home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / Locate.java < prev    next >
Text File  |  1998-11-02  |  2KB  |  94 lines

  1. package com.symantec.itools.tools.utilities;
  2.  
  3.  
  4. import java.applet.Applet;
  5. import java.util.Vector;
  6. import com.symantec.itools.lang.Classpath;
  7. import com.symantec.itools.lang.ClasspathEntry;
  8. import com.symantec.itools.lang.JavaName;
  9.  
  10.  
  11. /**
  12.  * @author Symantec Internet Tools Division
  13.  * @version 1.0
  14.  * @since VCafe 3.0
  15.  */
  16. public class Locate
  17.     extends Applet
  18. {
  19.     public Locate()
  20.     {
  21.     }
  22.  
  23.     public void init()
  24.     {
  25.         try
  26.         {
  27.             String location;
  28.             String name;
  29.  
  30.             name     = getParameter("searchName");
  31.             location = locate(name, System.getProperty("java.class.path"));
  32.  
  33.             if(location != null)
  34.             {
  35.                 System.out.println(name + " is located in " + location);
  36.             }
  37.             else
  38.             {
  39.                 System.out.println(name + " is not on the CLASSPATH");
  40.             }
  41.         }
  42.         catch(SecurityException ex)
  43.         {
  44.             System.out.println("Security exception");
  45.         }
  46.     }
  47.  
  48.     public static String locate(String name, String classpathString)
  49.     {
  50.         return (locate(name, new Classpath(classpathString)));
  51.     }
  52.  
  53.     public static String locate(String name, Classpath classpath)
  54.     {
  55.         ClasspathEntry entry;
  56.  
  57.         entry = classpath.find(name);
  58.  
  59.         if(entry == null)
  60.         {
  61.             return (null);
  62.         }
  63.  
  64.         return (entry.getName());        
  65.     }
  66.  
  67.     /**
  68.      * @param argv TODO
  69.      * @since VCafe 3.0
  70.      */
  71.  
  72.     public static void main(String[] argv)
  73.     {
  74.         String location;
  75.  
  76.         if(argv.length == 1)
  77.         {
  78.             location = locate(argv[0], System.getProperty("java.class.path"));
  79.         }
  80.         else
  81.         {
  82.             location = locate(argv[0], argv[1]);
  83.         }
  84.  
  85.         if(location != null)
  86.         {
  87.             System.out.println(argv[0] + " is located in " + location);
  88.         }
  89.         else
  90.         {
  91.             System.out.println(argv[0] + " is not on the CLASSPATH");
  92.         }
  93.     }
  94. }